<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "chat_source".
 *
 * @property integer $id
 * @property string $source_value
 * @property string $description
 */
class ChatSource extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'chat_source';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['source_value'], 'required'],
            [['source_value'], 'string', 'max' => 50],
            [['description'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'source_value' => 'Source Value',
            'description' => 'Description',
        ];
    }
    
    public function getAllSourceArr($fields=array()){
        $fields = empty($fields)?"*":implode(',', $fields);
        $result = (new \yii\db\Query())
                ->select($fields)
                ->from($this->tableName())
                ->all();
        return $result;
    }
    
    public function getAllSource(){
        $result = (new \yii\db\Query())
                ->select('*')
                ->from('chat_source')
                ->all();
        return $result;
    }
}
